package com.my.chapter9;

public class practice18 {
    public static void move(CycleFactory factory){
        Cycle c = factory.getCycle();
        c.move();
    }

    public static void main(String[] args) {
        move(new UnicycleFactory());
        move(new BicycleFactory());
        move(new TricycleFactory());
    }
}

interface Cycle{
    void move();
}

interface CycleFactory{
    Cycle getCycle();
}

class Unicycle implements Cycle{

    @Override
    public void move() {
        System.out.println("Unicycle.move()");
    }
}

class UnicycleFactory implements CycleFactory{

    @Override
    public Cycle getCycle() {
        return new Unicycle();
    }
}

class Bicycle implements Cycle{

    @Override
    public void move() {
        System.out.println("Bicycle.move()");
    }
}

class BicycleFactory implements CycleFactory{

    @Override
    public Cycle getCycle() {
        return new Bicycle();
    }
}

class Tricycle implements Cycle{

    @Override
    public void move() {
        System.out.println("Tricycle.move()");
    }
}

class TricycleFactory implements CycleFactory{

    @Override
    public Cycle getCycle() {
        return new Tricycle();
    }
}




